<%@ taglib prefix="fm" uri="http://www.springframework.org/tags/form" %>
<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <base href="${pageContext.request.contextPath}/"/>
    <link rel="stylesheet" href="abc/css/bootstrap.css">
</head>
<body>
<div class="container-fluid">
<h3>添加用户</h3>
<fm:form class="form-horizontal" method="post" modelAttribute="user">
    <div class="form-group">
        <label for="" class="control-label col-sm-3">用户编码：</label>
        <div class="col-sm-8">
            <input type="text" id="userCode" name="userCode" class="form-control"/>
            <span style="color:red" id="codeInfo"></span>
            <fm:errors path="userCode" cssStyle="color: red"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">用户名：</label>
        <div class="col-sm-8">
            <input type="text" name="userName" class="form-control"/>
            <fm:errors path="userName" cssStyle="color: red"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">电话：</label>
        <div class="col-sm-8">
            <input type="text" name="phone" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">地址:</label>
        <div class="col-sm-8">
            <input type="text" name="address" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">密码：</label>
        <div class="col-sm-8">
            <input type="text" name="userPassword" class="form-control"/>
            <fm:errors path="userPassword" cssStyle="color: red"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">性别：</label>
        <div class="col-sm-8">
            <label class="radio-inline">
              <input type="radio" name="gender" value="1" checked/>男
            </label>
            <label class="radio-inline">
               <input type="radio" name="gender" value="2"/>女
            </label>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">出生年月：</label>
        <div class="col-sm-8">
            <input type="text" name="birthday" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="control-label col-sm-3">角色：</label>
        <div class="col-sm-4">
           <select name="userRole" class="form-control">
            <option value="1">管理员</option>
               <option value="2">经理</option>
               <option value="3">普通员工</option>

           </select>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-4 col-sm-offset-4">
            <input type="submit" value="提交" class="btn btn-primary form-control"/>
        </div>
    </div>

</fm:form>

</div>
<script src="abc/js/jquery-1.12.4.js"></script>
<script src="abc/laydate/laydate.js"></script>
<script>
    laydate.render({
        elem: '[name=birthday]' //指定元素
    });

    $("#userCode").blur(function(){
        $.ajax({
            url:"user/exists",
            data:"userCode="+$("#userCode").val(),
            dataType:"json",
            type:"get",
            success:function(result){
                if(!result.flag){
                    $("#codeInfo").html("该账号不可用！");
                }else{
                    $("#codeInfo").html("该账号可以使用！");
                }
            }
        });
    });

</script>
</body>
</html>
